#include "BasicRefrenceCounter.h"

namespace utility
{
	BasicRefrenceCounter::BasicRefrenceCounter(void)
	{
		m_nRefrenceCount = 0;
	}

	BasicRefrenceCounter::~BasicRefrenceCounter(void)
	{
	}

	int BasicRefrenceCounter::AddRefrence()
	{
		int nRef = 0;
		m_optex.Enter();
		nRef = ++m_nRefrenceCount;
		m_optex.Leave();
		return nRef;
	}

	int BasicRefrenceCounter::ReleaseRefrence()
	{
		int nRef = 0;
		m_optex.Enter();
		nRef = m_nRefrenceCount>0?(--m_nRefrenceCount):(-1);
		m_optex.Leave();
		return nRef;
	}
}
